export default {
  checkValid(vm, key) {
    // incentive speed valid1 valid2
    vm.$validator.fields.items.forEach(item => {
      vm.$validator.validate(item.name, key[item.name]);
    });
    return vm.$validator.errors.items.length === 0;
  },
  findFirst(obj) {
    let k;
    for (k in obj) return k;
  },
  jsonStringify(obj) {
    let i,
      _obj = {};
    for (i in obj) {
      try {
        _obj[i] = JSON.stringify(obj[i]);
      } catch (e) {}
    }
    return _obj;
  },
  jsonParse(obj) {
    let i,
      _obj = {};
    for (i in obj) {
      try {
        _obj[i] = JSON.parse(obj[i]);
      } catch (e) {}
    }
    return _obj;
  }
};
